 /*	
   ______   ______    
  /\__  __\/\ \___\ 
  \/_/\ \_/\ \ \__/    __   __     __       
     \ \ \  \ \ \__\  /\ \ /\ \  /'__`\  
     _\_\ \  \ \ \_/_ \ \ \\_\ \/\  __/       
    /\____/   \ \_____\\ \_____/\ \____\   
    \_/__/     \/_____/ \/____/  \/____/                   
 
 	This file is part of the JEVE core API.

    JEve is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    JEve is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    Copyright 2008 JEve Project (JEveProject@gmail.com)
 */
package be.fomp.jeve.core.api.connectors;

 import be.fomp.jeve.core.api.FullAPI;
 import be.fomp.jeve.core.api.LimitedAPI;
 import be.fomp.jeve.core.api.StandardAPI;
 import be.fomp.jeve.core.config.CoreConfiguration;
 import be.fomp.jeve.core.config.CoreConfigurationImpl;
 import be.fomp.jeve.core.config.JEveConfiguration;
 import be.fomp.jeve.core.exceptions.JEveConfigurationException;
/**
 * <pre>
 *  ______   ______    
 * /\__  __\/\ \___\ 
 * \/_/\ \_/\ \ \__/    __   __     __       
 *    \ \ \  \ \ \__\  /\ \ /\ \  /'__`\  
 *    _\_\ \  \ \ \_/_ \ \ \\_\ \/\  __/       
 *   /\____/   \ \_____\\ \_____/\ \____\   
 *   \_/__/     \/_____/ \/____/  \/____/                   
 *</pre>
 *	This file is part of the JEVE core API.<br />
 *	<br />
 * 
 * This class contains provides the api connectors and initialises 
 * the configuration data for you.
 * 
 * @author Sven Meys
 */
public final class JEveConnectionFactory {
	/**
	 * A unique instance of the factory..only need one
	 */
	private static JEveConnectionFactory instance = null;
	
	/**
	 * The configuration object.
	 */
	private static CoreConfiguration config;
	
	/**
	 * This method initializes the factory and returns an instance of it.
	 * @return An instance of the factory
	 * @throws JEveConfigurationException When the configuration object failed to initialize.
	 */
	public static JEveConnectionFactory createFactory() throws JEveConfigurationException{
		if(instance == null) {
			instance = new JEveConnectionFactory();
		}
		return instance;
	}
	
	/**
	 * Private constructor which loads the configuration
	 * 
	 * @throws JEveConfigurationException when initializing the configuration failed
	 */
	private JEveConnectionFactory() throws JEveConfigurationException{
		config = new CoreConfigurationImpl();
	}
	
	/**
	 * This method returns a connector to use the standard API
	 * @return a standard API object
	 */
	public StandardAPI getStandardConnection()
	{
		return new StandardConnector(config);
	}
	
	/**
	 * This method returns a connector to use the limited API
	 * @return a limited API object
	 */
	public LimitedAPI getLimitedConnection()
	{
		return new LimitedConnector(config);
	}
	
	/**
	 * This method returns a connector to use the full API
	 * @return a full API object
	 */
	public FullAPI getFullConnection()
	{
		return new FullConnector(config);
	}
	
	/**
	 * Getter for the configuration
	 * @return The configuration object
	 */
	public JEveConfiguration getConfiguration(){
		return config;
	}
	
}
